package com.etc.ex;

/**
 * @author: mxt
 * @create: 2024-09-03 14:16
 * @Version 1.0
 **/
public class TestMax {
    /**
     * 三个数字中的最大值
     *
     * @param args
     */
    public static void main(String[] args) {

        //1. 先求两个数字中的最大值，然后再和第三个数字比较即可。
        int a = 1, b = 2, c = 3;
        int max = a; //假设a是最大值
        if (max < b) {
            max = b;
        }
        if (max < c) {
            max = c;
        }

        System.out.println("the max is :" + max);

        System.out.println("************************************");
        int x = 1, y = 2, z = 3;
        if (x >= y) {
            if (x >= z) {
                System.out.println("The max is :" + x);
            } else {    // x>=y && z>x
                System.out.println("The max is :" + z);
            }
        } else {
            //y>x
            if (y >= z) {
                System.out.println("The max is :" + y);
            } else { // y>x && z>y
                System.out.println("The max is :" + z);
            }

        }

    }
}
